package validation

import (
	"github.com/go-playground/validator/v10"
	"regexp"
)

// Mobile 手机号码验证器
var Mobile validator.Func = func(fl validator.FieldLevel) bool {
	pattern := `^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$`
	field, ok := fl.Field().Interface().(string)
	if !ok {
		return false
	}
	reg := regexp.MustCompile(pattern)
	return reg.MatchString(field)
}
